import request from '@/utils/request'

export function del(ids, cascade) {
  return request({
    url: 'api/flowable/definition',
    method: 'delete',
    params: {
      processDefinitionId: ids,
      cascade: cascade
    }
  })
}

export function edit(data) {
  return request({
    url: 'api/flowable/definition',
    method: 'put',
    data
  })
}

export function activate(data) {
  return request({
    url: 'api/flowable/definition/activate',
    method: 'put',
    data
  })
}

export function suspend(data) {
  return request({
    url: 'api/flowable/definition/suspend',
    method: 'put',
    data
  })
}

export function image(id) {
  return request({
    url: 'api/flowable/definition/image?processDefinitionId=' + id,
    method: 'get'
  })
}

export function getIdentityLink(id) {
  return request({
    url: 'api/flowable/definitionIdentityLink?processDefinitionId=' + id,
    method: 'get'
  })
}

export function addIdentityLink(data) {
  return request({
    url: 'api/flowable/definitionIdentityLink',
    method: 'post',
    data
  })
}

export function delIdentityLink(id, identityId, identityType) {
  return request({
    url: 'api/flowable/definitionIdentityLink',
    method: 'delete',
    params: {
      processDefinitionId: id,
      identityId: identityId,
      identityType: identityType
    }
  })
}

export function exportXML(id) {
  return request({
    url: 'api/flowable/definition/exportXML',
    method: 'get',
    params: {
      processDefinitionId: id
    },
    responseType: 'blob'
  })
}

export function renderedStartForm(id) {
  return request({
    url: 'api/flowable/definition/renderedStartForm',
    method: 'get',
    params: {
      processDefinitionId: id
    }
  })
}

export default { edit, del, activate, suspend, getIdentityLink, addIdentityLink, delIdentityLink, exportXML, renderedStartForm }
